package com.charonmc;

import com.charonmc.commands.Rank;
import com.charonmc.listeners.PlayerListenerLib;
import com.charonmc.utils.PapiUtils;
import com.charonmc.utils.PrefixUtils;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

/**
 * Bukkit插件主类
 */
public class CharonLib extends JavaPlugin {
    public static CharonLib instance;
    @Override
    public void onEnable() {
        instance = this;
        getLogger().info("start");
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
        Bukkit.getPluginManager().registerEvents(new PlayerListenerLib(), this);
        PrefixUtils.prefixTable.put(-1, "§7");
        PrefixUtils.prefixTable.put(0, "§8[§4服主§8]§4");
        PrefixUtils.prefixTable.put(1, "§8[§d管理§8]§d");
        PrefixUtils.prefixTable.put(2, "§8[§9监察§8]§9");
        PrefixUtils.prefixTable.put(3, "§8[§3实习监察§8]§3");
        PrefixUtils.prefixTable.put(4, "§8[§e金锭§8]§e");
        PrefixUtils.prefixTable.put(5, "§8[§b钻石§8]§b");
        PrefixUtils.prefixTable.put(6, "§8[§a绿宝石§8]§a");
        PrefixUtils.prefixTable.put(7, "§8[§5设计§8]§5");
        PrefixUtils.prefixTable.put(8, "§8[§c开发§8]§c");
        PrefixUtils.prefixTable.put(9, "§8[§6策划§8]§6");

        this.getCommand("Rank").setExecutor(new Rank());

        if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
            new PapiUtils().register();
        } else {
            getLogger().warning("Cant find papi!");
        }
    }
}
